<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>34题修改switch</title>
    <style>
        div {
            width: 100%;
            
        }
        span {
            display: block;
            width: 100%;
        }
    </style>
    <script>
        function getName() {
            var grade = prompt("请输入您的分数(0<=x<=100)");
            let gradeNum = parseInt(grade / 10);
            switch (gradeNum) {
                case 10:
                    alert("你的成绩等级为优秀");
                    break;
                case 9:
                    alert("你的成绩等级为优秀");
                    break;
                case 8:
                    alert("你的成绩等级为良好");
                    break;
                case 7:
                    alert("你的成绩等级为良好");
                    break;
                case 6:
                    alert("你的成绩等级为良好");
                    break;
                default:
                    alert("你的成绩等级为不及格，继续加油哦！");
            }
            
            let span = document.getElementById('span');
            if (gradeNum >= 9) {
                span.innerHTML = `您的分数${grade}，等级为优秀`;
            } else if (gradeNum >= 6 && gradeNum < 9) {
                span.innerHTML = `您的分数${grade}，等级为良好`;
            } else {
                span.innerHTML = `您的分数${grade}，不及格，要继续努力！`;
            }
        }
    </script>
</head>
<body>
    <div>
        点击按钮开始输入你的成绩<input type="button" value="点击输入" onclick="getName()">
        <span id="span"></span>
    </div>
</body>
</html>